Ejemplo n.º 1
0
class SSF(object):
    '''
    Service Sharing Facility.
    '''

    logger = logging.getLogger()

    PORT = 8888

    def __init__(self):
        logging.basicConfig(level=logging.DEBUG,
                            format="%(asctime)s [%(levelname)-7s] %(message)s")
        self.logger.info('Welcome to SSF')
        self.service = OCCI()

    def setup(self):
        '''
        Initialize the service.
        '''
        pass

    def start(self):
        '''
        Start the service.
        '''
        self.service.register_backend(AGREEMENT, AgreementHandler())
        self.logger.info('Starting Negotiation Service on port %i', self.PORT)
        self.service.start(self.PORT)
Ejemplo n.º 2
0
class TestService(unittest.TestCase):
    '''
    Test the service extension point.
    '''

    registry = NonePersistentRegistry()

    def setUp(self):
        self.service = OCCI()

    def test_init_for_sanity(self):
        '''
        Test constructor and initialization of service.
        '''
        self.assertTrue(self.registry.get_renderer('text/occi'))
        self.assertTrue(self.registry.get_renderer('text/plain'))
        self.assertTrue(self.registry.get_renderer('text/uri-list'))
        self.assertTrue(self.registry.get_renderer('text/html'))

        OCCI(registry=NonePersistentRegistry())

    def test_register_backend_for_failure(self):
        '''
        Test registration.
        '''
        back = ActionBackend()
        self.assertRaises(AttributeError, self.service.register_backend,
                          COMPUTE, back)
        try:
            OCCI(registry=dict())
        except AttributeError:
            pass
        else:
            self.assertFalse(True, 'Exception not thrown...')

    def test_register_backend_for_sanity(self):
        '''
        Test registration.
        '''
        back = KindBackend()
        back1 = MixinBackend()
        back2 = ActionBackend()
        self.service.register_backend(COMPUTE, back)
        self.service.register_backend(IPNETWORKINTERFACE, back1)
        self.service.register_backend(START, back2)

        self.assertTrue(self.registry.get_backend(COMPUTE) == back)
        self.assertTrue(self.registry.get_backend(IPNETWORKINTERFACE) == back1)
        self.assertTrue(self.registry.get_backend(START) == back2)

    def test_start_for_success(self):
        '''
        Just here to reach 100% code coverage :-)
        '''
        self.service.http_server.listen = fake_listen
        tornado.ioloop.IOLoop.instance = fake_ioloop
        self.service.start(1010)
Ejemplo n.º 3
0
class TestService(unittest.TestCase):
    """
    Test the service extension point.
    """

    registry = NonePersistentRegistry()

    def setUp(self):
        self.service = OCCI()

    def test_init_for_sanity(self):
        """
        Test constructor and initialization of service.
        """
        self.assertTrue(self.registry.get_renderer("text/occi"))
        self.assertTrue(self.registry.get_renderer("text/plain"))
        self.assertTrue(self.registry.get_renderer("text/uri-list"))
        self.assertTrue(self.registry.get_renderer("text/html"))

        OCCI(registry=NonePersistentRegistry())

    def test_register_backend_for_failure(self):
        """
        Test registration.
        """
        back = ActionBackend()
        self.assertRaises(AttributeError, self.service.register_backend, COMPUTE, back)
        try:
            OCCI(registry=dict())
        except AttributeError:
            pass
        else:
            self.assertFalse(True, "Exception not thrown...")

    def test_register_backend_for_sanity(self):
        """
        Test registration.
        """
        back = KindBackend()
        back1 = MixinBackend()
        back2 = ActionBackend()
        self.service.register_backend(COMPUTE, back)
        self.service.register_backend(IPNETWORKINTERFACE, back1)
        self.service.register_backend(START, back2)

        self.assertTrue(self.registry.get_backend(COMPUTE) == back)
        self.assertTrue(self.registry.get_backend(IPNETWORKINTERFACE) == back1)
        self.assertTrue(self.registry.get_backend(START) == back2)

    def test_start_for_success(self):
        """
        Just here to reach 100% code coverage :-)
        """
        self.service.http_server.listen = fake_listen
        tornado.ioloop.IOLoop.instance = fake_ioloop
        self.service.start(1010)
Ejemplo n.º 4
0
    STORAGE_LINK_BACKEND = StorageLinkBackend()
    NETWORKINTERFACE_BACKEND = NetworkInterfaceBackend()

    SERVICE = OCCI()

    SERVICE.register_backend(COMPUTE, COMPUTE_BACKEND)
    SERVICE.register_backend(START, COMPUTE_BACKEND)
    SERVICE.register_backend(STOP, COMPUTE_BACKEND)
    SERVICE.register_backend(RESTART, COMPUTE_BACKEND)
    SERVICE.register_backend(SUSPEND, COMPUTE_BACKEND)

    SERVICE.register_backend(NETWORK, NETWORK_BACKEND)
    SERVICE.register_backend(UP, NETWORK_BACKEND)
    SERVICE.register_backend(DOWN, NETWORK_BACKEND)

    SERVICE.register_backend(STORAGE, STORAGE_BACKEND)
    SERVICE.register_backend(ONLINE, STORAGE_BACKEND)
    SERVICE.register_backend(OFFLINE, STORAGE_BACKEND)
    SERVICE.register_backend(BACKUP, STORAGE_BACKEND)
    SERVICE.register_backend(SNAPSHOT, STORAGE_BACKEND)
    SERVICE.register_backend(RESIZE, STORAGE_BACKEND)

    SERVICE.register_backend(IPNETWORK, IPNETWORK_BACKEND)
    SERVICE.register_backend(IPNETWORKINTERFACE, IPNETWORKINTERFACE_BACKEND)

    SERVICE.register_backend(STORAGELINK, STORAGE_LINK_BACKEND)
    SERVICE.register_backend(NETWORKINTERFACE, NETWORKINTERFACE_BACKEND)

    SERVICE.start(8888)