def __init__(self):
        py_vmomi_service = pyVmomiService(SmartConnect, Disconnect)
        cloudshell_data_retriever_service = CloudshellDataRetrieverService()
        resource_connection_details_retriever = ResourceConnectionDetailsRetriever(
            helpers, cloudshell_data_retriever_service)
        resource_remover = CloudshellResourceRemover(helpers)
        command_wrapper = CommandWrapper(getLogger, py_vmomi_service)
        template_deployer = VirtualMachineDeployer(py_vmomi_service,
                                                   generate_unique_name)

        deploy_from_template_command = DeployFromTemplateCommand(
            template_deployer)

        resource_model_parser = ResourceModelParser()
        vc_model_retriever = VCenterDataModelRetriever(helpers,
                                                       resource_model_parser)
        vc_data_model = vc_model_retriever.get_vcenter_data_model()

        #vnic_to_network_mapper = VnicToNetworkMapper(name_generator, vc_data_model.default_network)
        port_group_name_generator = DvPortGroupNameGenerator()
        vnic_to_network_mapper = VnicToNetworkMapper(port_group_name_generator)

        # Virtual Switch Connect
        synchronous_task_waiter = SynchronousTaskWaiter()
        dv_port_group_creator = DvPortGroupCreator(py_vmomi_service,
                                                   synchronous_task_waiter)
        virtual_machine_port_group_configurer = VirtualMachinePortGroupConfigurer(
            py_vmomi_service, synchronous_task_waiter, vnic_to_network_mapper,
            VNicService())
        virtual_switch_to_machine_connector = VirtualSwitchToMachineConnector(
            dv_port_group_creator, virtual_machine_port_group_configurer)

        virtual_switch_connect_command = VirtualSwitchConnectCommand(
            py_vmomi_service, virtual_switch_to_machine_connector,
            DvPortGroupNameGenerator(), VlanSpecFactory(), VLanIdRangeParser(),
            getLogger('VirtualSwitchConnectCommand'))

        # Virtual Switch Revoke
        virtual_switch_disconnect_command = \
            VirtualSwitchToMachineDisconnectCommand(py_vmomi_service,
                                                    virtual_machine_port_group_configurer,
                                                    vc_data_model.default_network)

        destroy_virtual_machine_command = DestroyVirtualMachineCommand(
            py_vmomi_service, resource_remover,
            virtual_switch_disconnect_command)
        # Power Command
        vm_power_management_command = VirtualMachinePowerManagementCommand(
            py_vmomi_service, synchronous_task_waiter)
        # Refresh IP command
        refresh_ip_command = RefreshIpCommand(
            py_vmomi_service, cloudshell_data_retriever_service, helpers,
            resource_model_parser)

        self.commandExecuterService = CommandExecuterService(
            jsonpickle, helpers, command_wrapper,
            resource_connection_details_retriever, vc_data_model,
            destroy_virtual_machine_command, deploy_from_template_command,
            virtual_switch_connect_command, virtual_switch_disconnect_command,
            vm_power_management_command, refresh_ip_command)
Example #2
0
    def __init__(self, action, name='', logger=None):
        self.action = action
        self.name = name
        self._print_format = '{0} ran: {1} times - total: {2} (sec) avg: {3} (sec)'

        if logger is None:
            logger = getLogger('performance')
        self.logger = logger
    def __init__(self, action, name="", logger=None):
        self.action = action
        self.name = name
        self._print_format = "{0} ran: {1} times - total: {2} (sec) avg: {3} (sec)"

        if logger is None:
            logger = getLogger("performance")
        self.logger = logger
Example #4
0
class httpUtils:
    logger = getLogger('test')

    def get(self, url, params: dict = None, headers: dict = None):
        res = requests.get(url, data=params, headers=headers)
        self.logger.info("请求路径:" + res.request.url)
        headerStr = ""
        for headerKey in res.request.headers:
            headerStr = headerStr + "\n" + headerKey + ":" + res.request.headers[
                headerKey]
        self.logger.info("请求头信息:" + headerStr)
        self.logger.info("请求参数:\n" + res.request.body)

        resHeaderStr = ""
        for resHeaderKey in res.headers:
            resHeaderStr = resHeaderStr + "\n" + resHeaderKey + ":" + res.headers[
                resHeaderKey]
        self.logger.info("响应头信息:" + resHeaderStr)
        self.logger.info("返回结果:\n" + res.content.decode("utf-8"))
        return res

    def post(self, url, params: dict = None, headers: dict = None):
        res = requests.post(url, data=params, headers=headers)
        self.logger.info("请求路径:" + res.request.url)
        headerStr = ""
        for headerKey in res.request.headers:
            headerStr = headerStr + "\n" + headerKey + ":" + res.request.headers[
                headerKey]
        self.logger.info("请求头信息:" + headerStr)
        self.logger.info("请求参数:\n" + res.request.body)

        resHeaderStr = ""
        for resHeaderKey in res.headers:
            resHeaderStr = resHeaderStr + "\n" + resHeaderKey + ":" + res.headers[
                resHeaderKey]
        self.logger.info("响应头信息:" + resHeaderStr)
        self.logger.info("返回结果:\n" + res.content.decode("utf-8"))
        return res
    def __init__(self):
        py_vmomi_service = pyVmomiService(SmartConnect, Disconnect)
        cloudshell_data_retriever_service = CloudshellDataRetrieverService()
        resource_connection_details_retriever = ResourceConnectionDetailsRetriever(helpers,
                                                                                   cloudshell_data_retriever_service)
        resource_remover = CloudshellResourceRemover(helpers)
        command_wrapper = CommandWrapper(getLogger, py_vmomi_service)
        template_deployer = VirtualMachineDeployer(py_vmomi_service, generate_unique_name)

        deploy_from_template_command = DeployFromTemplateCommand(template_deployer)

        resource_model_parser = ResourceModelParser()
        vc_model_retriever = VCenterDataModelRetriever(helpers, resource_model_parser)
        vc_data_model = vc_model_retriever.get_vcenter_data_model()

        #vnic_to_network_mapper = VnicToNetworkMapper(name_generator, vc_data_model.default_network)
        port_group_name_generator = DvPortGroupNameGenerator()
        vnic_to_network_mapper = VnicToNetworkMapper(port_group_name_generator)

        # Virtual Switch Connect
        synchronous_task_waiter = SynchronousTaskWaiter()
        dv_port_group_creator = DvPortGroupCreator(py_vmomi_service, synchronous_task_waiter)
        virtual_machine_port_group_configurer = VirtualMachinePortGroupConfigurer(py_vmomi_service,
                                                                                  synchronous_task_waiter,
                                                                                  vnic_to_network_mapper,
                                                                                  VNicService())
        virtual_switch_to_machine_connector = VirtualSwitchToMachineConnector(dv_port_group_creator,
                                                                              virtual_machine_port_group_configurer)

        virtual_switch_connect_command = VirtualSwitchConnectCommand(py_vmomi_service,
                                                                     virtual_switch_to_machine_connector,
                                                                     DvPortGroupNameGenerator(),
                                                                     VlanSpecFactory(),
                                                                     VLanIdRangeParser(),
                                                                     getLogger('VirtualSwitchConnectCommand'))

        # Virtual Switch Revoke
        virtual_switch_disconnect_command = \
            VirtualSwitchToMachineDisconnectCommand(py_vmomi_service,
                                                    virtual_machine_port_group_configurer,
                                                    vc_data_model.default_network)

        destroy_virtual_machine_command = DestroyVirtualMachineCommand(py_vmomi_service,
                                                                       resource_remover,
                                                                       virtual_switch_disconnect_command)
        # Power Command
        vm_power_management_command = VirtualMachinePowerManagementCommand(py_vmomi_service,
                                                                           synchronous_task_waiter)
        # Refresh IP command
        refresh_ip_command = RefreshIpCommand(py_vmomi_service, cloudshell_data_retriever_service, helpers,
                                              resource_model_parser)

        self.commandExecuterService = CommandExecuterService(jsonpickle,
                                                             helpers,
                                                             command_wrapper,
                                                             resource_connection_details_retriever,
                                                             vc_data_model,
                                                             destroy_virtual_machine_command,
                                                             deploy_from_template_command,
                                                             virtual_switch_connect_command,
                                                             virtual_switch_disconnect_command,
                                                             vm_power_management_command,
                                                             refresh_ip_command)
# -*- coding: utf-8 -*-

from pyVmomi import vim
from models.VirtualNicModel import VirtualNicModel
from common.logger import getLogger

_logger = getLogger("vCenterShell")


# @todo very much trivial implementation. Should be moved & expanded
class ConnectionException(Exception):
    pass


class NetworkAdaptersRetrieverCommand(object):
    def __init__(self, pv_service):
        """
        :param pv_service: <common.pv_service obj>
        :return:
        """
        self.pv_service = pv_service

    def retrieve(self, si, path, network_name):
        """
        Retrieve Network by Name
        :param si: <service instance>
        :param path: <str> the path to find the vm network
        :param network_name: <str>
        :return: <list of 'VirtualNicModel'>
        """
        _logger.debug("Retrieving Network... Path: '{0}' Name: '{1}'".format(path, network_name))
import sys
import os
import argparse
import glob

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import common.subregion_descriptor as subrgn_descrptr
import common.subregion_image as sbrgn_image
import common.utilities as utils
import thirdparty.edk2_capsule_tool.GenerateCapsule as generate_capsule_tool
from common.siip_constants import VERSION as __version__
from common.banner import banner
import common.logger as logging

logger = logging.getLogger("subregion_capsule")

if sys.version_info < (3, 6):
    raise Exception("Python 3.6 is the minimal version required")

#
# Globals for help information
#
__prog__ = "subregion_capsule"

TOOLNAME = "Sub-Region Capsule Tool"

banner(TOOLNAME, __version__)


def generate_sub_region_fv(image_file,
import qualipy.scripts.cloudshell_scripts_helpers as helpers
from qualipy.api.cloudshell_api import *
from common.logger import getLogger

logger = getLogger("App Orchestration Driver")


def execute_app_orchestration():
    # Retrieve data from environment variables
    reservation_id = helpers.get_reservation_context_details().id
    resource_details = helpers.get_resource_context_details_dict()
    helpers.get_resource_context_details()
    app_name = resource_details["name"]
    deployment_service = resource_details["appData"]["deploymentService"][
        "name"]
    installation_service_data = resource_details["appData"][
        "installationService"]

    # Start api session
    api = helpers.get_api_session()

    # execute deploy app
    deployment_result = deploy_app(api, app_name, deployment_service,
                                   reservation_id)

    # if visual connector endpoints contains service with attribute "Virtual Network" execute connect command
    # TODO

    # TODO this is temporary until we move to drivers
    api.SetAttributesValues([
        ResourceAttributesUpdateRequest(
Example #9
0
# -*- coding: utf-8 -*-

import allure
from appium.webdriver.common.touch_action import TouchAction
from common.logger import getLogger

logger = getLogger('todolist')


@allure.feature('待办事项')
class Test_todolist(object):
    @allure.story('登录')
    def test_login(self, driver):
        # 输入用户名
        driver.find_element_by_id('com.example.todolist:id/nameET').send_keys(
            1)
        # 输入密码
        driver.find_element_by_id(
            'com.example.todolist:id/passwordET').send_keys(1)
        # 点击登录
        driver.find_element_by_id('com.example.todolist:id/loginBtn').click()

    @allure.story('添加待办')
    def test_addDetail(self, driver):
        # 点击添加按钮
        driver.find_element_by_id('com.example.todolist:id/action_new').click()
        # 添加内容
        driver.find_element_by_id(
            'com.example.todolist:id/toDoItemDetailET').send_keys('1')
        # 点击保存
        driver.find_element_by_id('com.example.todolist:id/saveBtn').click()
Example #10
0
import qualipy.scripts.cloudshell_scripts_helpers as helpers
from qualipy.api.cloudshell_api import AttributeNameValue
from common.model_factory import ResourceModelParser
from vlan_service.resolver.provider import VlanResolverProvider
from common.utilites.command_result import set_command_result
from common.logger import getLogger

_logger = getLogger('VlanAuto')


def main():
    # get vlan auto resource model
    resource_context = helpers.get_resource_context_details()
    resource_model_parser = ResourceModelParser()
    vlan_auto_resource_model = resource_model_parser.convert_to_resource_model(resource_context)
    # get reservation details
    reservation_context = helpers.get_reservation_context_details()
    # Start api session
    api = helpers.get_api_session()

    vlan_service_provider = VlanResolverProvider(vlan_resource_model=vlan_auto_resource_model,
                                                 pool_id=reservation_context.domain,
                                                 reservation_id=reservation_context.id,
                                                 owner_id=resource_context.name,
                                                 api=api)

    if not vlan_service_provider.is_vlan_resolved():
        # resolve vlan id
        vlan_id = vlan_service_provider.resolve_vlan_auto()
        vlan_id = str(vlan_id)
        # set resolved vlan id to virtual network attribute
Example #11
0
# -*- coding: utf-8 -*-

"""
Very much common Input/Output Utils
"""

import os.path

from common.logger import getLogger
_logger = getLogger("vCenterCommon")


def extract_folder_name(whole_path):
    if whole_path:
        folder, name = os.path.split(whole_path)
        return folder
    return None


def compose_folder_if_not_existed(whole_path):
    if whole_path and not os.path.exists(whole_path):
        os.makedirs(whole_path)
        _logger.debug(u"Folder composed: '{}'".format(whole_path))


def get_path_and_name(full_name):
    """
    Split Whole Patch onto 'Patch' and 'Name'
    :param full_name: <str> Full Resource Name - likes 'Root/Folder/Folder2/Name'
    :return: tuple (Patch, Name)
    """
# -*- coding: utf-8 -*-
"""
Pretty much trivial logging demo

Default log file - './logs/vCenter.log'
"""

from common.logger import getLogger
from common.logger import configure_loglevel

_logger = getLogger(__name__)           # Default logger is using
# _logger = getLogger("vCenterShell")     # for Shell App itself
# _logger = getLogger("vCenterCommon")    # for Common Utilises

# ONLY IF YOU WANTED CONFIGURE LOG MANUALLY
configure_loglevel("INFO", "INFO", "../../logs/vCenter.log")

if __name__ == "__main__":
    _logger.debug("DEBUG SHOULD BE SKIPPED")
    _logger.info("INFO IS OK")
    _logger.warn("WARNING IS OK")
    _logger.error("ERROR IS OK!!!")
    _logger.critical("CRITICAL IS OK ?!!!!")
Example #13
0
 def test_getlogger(self):
     logger = getLogger(__name__)
     self.assertEqual(logger.propagate, True)
     self.assertEqual(logger.name, __name__)
Example #14
0
# -*- coding: utf-8 -*-
"""
Very much common Input/Output Utils
"""

import os.path

from common.logger import getLogger
_logger = getLogger("vCenterCommon")


def extract_folder_name(whole_path):
    if whole_path:
        folder, name = os.path.split(whole_path)
        return folder
    return None


def compose_folder_if_not_existed(whole_path):
    if whole_path and not os.path.exists(whole_path):
        os.makedirs(whole_path)
        _logger.debug(u"Folder composed: '{}'".format(whole_path))


def get_path_and_name(full_name):
    """
    Split Whole Patch onto 'Patch' and 'Name'
    :param full_name: <str> Full Resource Name - likes 'Root/Folder/Folder2/Name'
    :return: tuple (Patch, Name)
    """
    if full_name:
import qualipy.scripts.cloudshell_scripts_helpers as helpers
from qualipy.api.cloudshell_api import *
from common.logger import getLogger

logger = getLogger("App Orchestration Driver")


def execute_app_orchestration():
    # Retrieve data from environment variables
    reservation_id = helpers.get_reservation_context_details().id
    resource_details = helpers.get_resource_context_details_dict()
    helpers.get_resource_context_details()
    app_name = resource_details["name"]
    deployment_service = resource_details["appData"]["deploymentService"]["name"]
    installation_service_data = resource_details["appData"]["installationService"]

    # Start api session
    api = helpers.get_api_session()

    # execute deploy app
    deployment_result = deploy_app(api, app_name, deployment_service, reservation_id)

    # if visual connector endpoints contains service with attribute "Virtual Network" execute connect command
    # TODO

    # TODO this is temporary until we move to drivers
    api.SetAttributesValues(
            [ResourceAttributesUpdateRequest(
                    deployment_result.LogicalResourceName,
                    [AttributeNameValue("VM_UUID", deployment_result.VmUuid),
                     AttributeNameValue("Cloud Provider", deployment_result.CloudProviderResourceName)])])
Example #16
0
def registerLogger(application: FastAPI, name: str):
    if settings.logs_enable:
        application.logger = getLogger(name)
    pass
 def __init__(self, method_ame="runTest"):
     super(SearchObjectsPerfTest, self).__init__(method_ame)
     cred = TestCredentials()
     self.pv_service = pyVmomiService(SmartConnect, Disconnect)
     self.si = self.pv_service.connect(cred.host, cred.username, cred.password)
     self.logger = getLogger("performance")
Example #18
0
import os
import sys
import argparse
from datetime import datetime

from enum import Enum
import struct
from ctypes import Structure
from ctypes import c_char, c_uint32, c_uint8, c_uint64, c_uint16, sizeof, ARRAY

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from common.siip_constants import VERSION as __version__
from common.banner import banner
import common.logger as logging

logger = logging.getLogger("siip_sign")

try:
    from cryptography.hazmat.primitives import hashes as hashes
    from cryptography.hazmat.primitives import serialization as serialization
    from cryptography.hazmat.backends import default_backend
    from cryptography.hazmat.primitives.asymmetric import padding as crypto_padding

    # Check its version
    import cryptography

    if cryptography.__version__ < "2.2.2":
        logger.critical("Error: Cryptography version must be 2.2.2 or higher"
                        " (installed version: {})".format(
                            cryptography.__version__))
        exit(1)
Example #19
0
# -*- coding:utf-8 -*-
import schedule, time, sys, os

sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

from weiyi.department import DepartmentInfo
from weiyi.doctor import DoctorInfo
from weiyi.hospital import HospitalLinkCache, HospitalInfo
from common.tools import timethis
from common.logger import getLogger

logger = getLogger('hospital')


def update_one_hospital(url):
    hospital = HospitalInfo()
    hospital.update_one(url)
    for section_link in hospital.section_links:
        department = DepartmentInfo()
        department.update_one(section_link)
        for doctor_link in department.doctor_links:
            DoctorInfo().update_one(doctor_link)


@timethis
def main():
    HospitalLinkCache().start()
    logger.info('hospital link cache done!')
    HospitalInfo().start()
    logger.info('hospital info done!')
    DepartmentInfo().start()
from ModelingMachine.engine.new_partition import NewPartition
from ModelingMachine.engine.tasks.base_modeler import BaseModeler
from ModelingMachine.engine.tasks.glm import GLMG, GLMB
from ModelingMachine.engine.tasks.rf import RFC, RFR
from ModelingMachine.engine.tasks.lasso_ridge import RegL2
from ModelingMachine.engine.tasks.sgd import SGDC, SGDR
from ModelingMachine.engine.tasks.cart import CARTClassifier, CARTRegressor
from ModelingMachine.engine.tasks.svc import SVMC, SVMR
from ModelingMachine.engine.tasks import gbm
from common.engine import metrics
from common.logger import logger as getLogger

from base_task_test import BaseTaskTest


logger = getLogger()


def create_correlated_test_data(reverse=False):
    ''' Create a test Container for X and ndarray for Y.
        One of the columns in X is a perfect predictor of Y.
    '''
    np.random.seed(1234)
    X = Container()
    X.add(np.random.rand(100), colnames=['rand'])
    if reverse:
        X.add(np.arange(100)[::-1], colnames=['linear'])
        Y = np.arange(100)[::-1]
    else:
        X.add(np.arange(100), colnames=['linear'])
        Y = np.arange(100)
Example #21
0
# -*- coding: utf-8 -*-
"""
Pretty much trivial logging demo

Default log file - './logs/vCenter.log'
"""

from common.logger import getLogger
from common.logger import configure_loglevel

_logger = getLogger(__name__)  # Default logger is using
# _logger = getLogger("vCenterShell")     # for Shell App itself
# _logger = getLogger("vCenterCommon")    # for Common Utilises

# ONLY IF YOU WANTED CONFIGURE LOG MANUALLY
configure_loglevel("INFO", "INFO", "../../logs/vCenter.log")

if __name__ == "__main__":
    _logger.debug("DEBUG SHOULD BE SKIPPED")
    _logger.info("INFO IS OK")
    _logger.warn("WARNING IS OK")
    _logger.error("ERROR IS OK!!!")
    _logger.critical("CRITICAL IS OK ?!!!!")
import qualipy.scripts.cloudshell_scripts_helpers as helpers
from qualipy.api.cloudshell_api import InputNameValue
from common.utilites.command_result import get_result_from_command_output, set_command_result, transfer_command_result
from common.logger import getLogger

_logger = getLogger('DeployedAppService')


#################################################
# === Should run under Deployed App context === #
#################################################


class DeployedAppService(object):
    def __init__(self, resource_model_parser):
        self.resource_model_parser = resource_model_parser
        self.resource_context = helpers.get_resource_context_details()
        self.generic_deployed_app_resource_model = self.resource_model_parser.convert_to_resource_model(
                self.resource_context)

    def connect(self):
        """
        Connect method should be executed on Deployed App
        It executes connect command on vCenter resource for each connected VLAN
        """
        vlan_spec_type = helpers.get_user_param('VLAN_SPEC_TYPE')

        if not vlan_spec_type:
            raise ValueError('VLAN_SPEC_TYPE is missing')

        vlan_id = helpers.get_user_param('VLAN_ID')
Example #23
0
from common.ifwi import IFWI_IMAGE
from common.firmware_volume import FirmwareDevice
from common.siip_constants import IP_OPTIONS
from common.tools_path import FMMT, GENFV, GENFFS, GENSEC, LZCOMPRESS, TOOLS_DIR
from common.tools_path import RSA_HELPER, FMMT_CFG
from common.siip_constants import VERSION as __version__
from common.banner import banner
import common.logger as logging

__prog__ = "siip_stitch"

TOOLNAME = "SIIP Stitching Tool"

banner(TOOLNAME, __version__)

logger = logging.getLogger("siip_stitch")

if sys.version_info < (3, 6):
    raise Exception("Python 3.6 is the minimal version required")

GUID_FFS_OBBPEI_HASH = uuid.UUID("F57757FC-2603-404F-AAE2-34C6232388E8")
GUID_FFS_OBBDXE_HASH = uuid.UUID("32198477-7337-40E4-897D-BC33F018B42F")

# Region for OBBPEI digest
GUID_FVOSBOOT = uuid.UUID("13BF8810-75FD-4B1A-91E6-E16C4201F80A")
GUID_FVUEFIBOOT = uuid.UUID("0496D33D-EA79-495C-B65D-ABF607184E3B")
GUID_FVADVANCED = uuid.UUID("B23E7388-9953-45C7-9201-0473DDE5487A")

# Region for OBBDXE digest
GUID_FVPOSTMEMORY = uuid.UUID("9DFE49DB-8EF0-4D9C-B273-0036144DE917")
GUID_FVFSPS = uuid.UUID(
Example #24
0
import json
import logging
import sys

from swiftclient.exceptions import ClientException

import utils
from common import swift
from common.config import settings
from common.logger import getLogger
logger = getLogger(__name__)


def apply_status(package_list, status):
    """
    Add or update status to packages in a list
    """
    dest = []
    if package_list is not None and len(package_list) > 0:
        for pkg in package_list:
            pkg['status'] = status
            dest.append(pkg)

    return dest


def filter_packages(files, **kwargs):
    """
    Get a list of package manifests by filters
    """
    keyword = ''
import unittest
from datetime import datetime

from mock import Mock, MagicMock, create_autospec
from pyVim.connect import SmartConnect, Disconnect
from pyVmomi import vim

from common.logger.service import LoggingService
from common.vcenter.vmomi_service import pyVmomiService
from tests.utils.testing_credentials import TestCredentials

sys.path.append(os.path.join(os.path.dirname(__file__), '../vCenterShell'))

from common.logger import getLogger

logger = getLogger(__name__)


class ignore_test_common_pyvmomi(unittest.TestCase):
    def setUp(self):
        LoggingService("CRITICAL", "DEBUG", None)
        pass

    def tearDown(self):
        pass

    def integration_clone_vm_destory(self):
        """
        Checks whether clone_vm and destroy methods works
        """
        '#arrange'
import qualipy.scripts.cloudshell_scripts_helpers as helpers
from qualipy.api.cloudshell_api import InputNameValue
from common.utilites.command_result import get_result_from_command_output, set_command_result, transfer_command_result
from common.logger import getLogger

_logger = getLogger('DeployedAppService')

#################################################
# === Should run under Deployed App context === #
#################################################


class DeployedAppService(object):
    def __init__(self, resource_model_parser):
        self.resource_model_parser = resource_model_parser
        self.resource_context = helpers.get_resource_context_details()
        self.generic_deployed_app_resource_model = self.resource_model_parser.convert_to_resource_model(
            self.resource_context)

    def connect(self):
        """
        Connect method should be executed on Deployed App
        It executes connect command on vCenter resource for each connected VLAN
        """
        vlan_spec_type = helpers.get_user_param('VLAN_SPEC_TYPE')

        if not vlan_spec_type:
            raise ValueError('VLAN_SPEC_TYPE is missing')

        vlan_id = helpers.get_user_param('VLAN_ID')
        if not vlan_id:
Example #27
0
import qualipy.scripts.cloudshell_scripts_helpers as helpers
from qualipy.api.cloudshell_api import AttributeNameValue
from common.model_factory import ResourceModelParser
from vlan_service.resolver.provider import VlanResolverProvider
from common.utilites.command_result import set_command_result
from common.logger import getLogger

_logger = getLogger('VlanAuto')


def main():
    # get vlan auto resource model
    resource_context = helpers.get_resource_context_details()
    resource_model_parser = ResourceModelParser()
    vlan_auto_resource_model = resource_model_parser.convert_to_resource_model(
        resource_context)
    # get reservation details
    reservation_context = helpers.get_reservation_context_details()
    # Start api session
    api = helpers.get_api_session()

    vlan_service_provider = VlanResolverProvider(
        vlan_resource_model=vlan_auto_resource_model,
        pool_id=reservation_context.domain,
        reservation_id=reservation_context.id,
        owner_id=resource_context.name,
        api=api)

    if not vlan_service_provider.is_vlan_resolved():
        # resolve vlan id
        vlan_id = vlan_service_provider.resolve_vlan_auto()
Example #28
0
import os
import sys
import subprocess
import argparse
import uuid
import struct
import re
from pathlib import Path

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from common.siip_constants import VERSION as __version__
from common.banner import banner
import common.utilities as utils
import common.logger as logging

LOGGER = logging.getLogger("subregion_sign")

__prog__ = "subregion_sign"

TOOLNAME = "Sub-Region Signing Tool"

banner(TOOLNAME, __version__)

if sys.version_info < (3, 6):
    raise Exception("Python 3.6 is the minimal version required")


class UefiSubregAuthenClass:
    """ Class define EFI subreation Authentication class """

    # typedef struct {
Example #29
0
# -*- coding:utf-8 -*-
from common import logger
from common.tools import singleton
from pymongo import MongoClient

logger = logger.getLogger('db_operator')


@singleton
class HandleMongo(object):
    def __init__(self, host=None, db=None):
        assert host and db
        self.host = host
        self._db = db
        self.client = None
        self.db = None

    def connect(self):
        try:
            self.client = MongoClient(self.host)
            self.db = self.client[self._db]
        except:
            logger.error('Server not available, Check your uri!')

    def get_state(self):
        return self.client is not None and self.db is not None

    def check_state(self, func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if self.get_state():