You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum from network.exceptions.packetException import PacketException # Packet type enum type. DO NOT MODIFY! Packet_TYPE = enum('DATA') # Data type enum type. DO NOT MOFIFY! _DATA_TYPE = enum("INT", "LONG", "STRING", "FLOAT") _max_packet_length = 64 * 1024 # 64 KB class _Packet(object): """ These objects stand for network packets. @attention: in order to avoid priority issues that can cause errors or malfunctions in the network subsystem, _Packet instances MUST be created through a NetworkManager object. @attention: The single underscore methods are semi-private, and MUST NOT be used at the user's code. """ def __init__(self, packetType=Packet_TYPE.DATA, priority= 10):
CygnusCloud ======================================================================== File: packet_t.py Version: 2.0 Description: image repository packet types definition Copyright 2012-13 Luis Barrios Hernández, Adrián Fernández Hernández, Samuel Guayerbas Martín Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum PACKET_T = enum("HALT", "ADD_IMAGE", "ADDED_IMAGE_ID", "RETR_REQUEST", "RETR_REQUEST_RECVD", "RETR_REQUEST_ERROR", "RETR_START", "RETR_ERROR", "STOR_REQUEST", "STOR_REQUEST_RECVD", "STOR_REQUEST_ERROR", "STOR_START", "STOR_ERROR", "DELETE_REQUEST", "DELETE_REQUEST_RECVD", "DELETE_REQUEST_ERROR", "STATUS_REQUEST", "STATUS_DATA", "CANCEL_EDITION", "IMAGE_EDITION_CANCELLED")
# -*- coding: utf8 -*- ''' ======================================================================== CygnusCloud ======================================================================== File: server_state_t.py Version: 2.0 Description: server state enum type Copyright 2012-13 Luis Barrios Hernández, Adrián Fernández Hernández, Samuel Guayerbas Martín Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum SERVER_STATE_T = enum("BOOTING", "READY", "SHUT_DOWN", "RECONNECTING", "CONNECTION_TIMED_OUT")
File: packet_t.py Version: 6.0 Description: virtual machine server packet types definition Copyright 2012-13 Luis Barrios Hernández, Adrián Fernández Hernández, Samuel Guayerbas Martín Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum VM_SERVER_PACKET_T = enum( "CREATE_DOMAIN", "DESTROY_DOMAIN", "REBOOT_DOMAIN", "DOMAIN_CONNECTION_DATA", "SERVER_STATUS", "SERVER_STATUS_REQUEST", "USER_FRIENDLY_SHUTDOWN", "HALT", "QUERY_ACTIVE_VM_DATA", "ACTIVE_VM_DATA", "QUERY_ACTIVE_DOMAIN_UIDS", "ACTIVE_DOMAIN_UIDS", "IMAGE_EDITION", "IMAGE_EDITION_ERROR", "DEPLOY_IMAGE", "IMAGE_DEPLOYMENT_ERROR", "DELETE_IMAGE", "IMAGE_DELETION_ERROR", "IMAGE_EDITED", "IMAGE_DEPLOYED", "IMAGE_DELETED", "INTERNAL_ERROR")
# -*- coding: UTF8 -*- ''' Definiciones del gestor de comandos @author: Luis Barrios Hernández @version: 1.5 ''' from ccutils.enums import enum COMMAND_TYPE = enum("REGISTER_VM_SERVER", "UNREGISTER_OR_SHUTDOWN_VM_SERVER", "BOOTUP_VM_SERVER", "VM_BOOT_REQUEST", "HALT", "DESTROY_DOMAIN", "VM_SERVER_CONFIGURATION_CHANGE") COMMAND_OUTPUT_TYPE = enum("VM_SERVER_REGISTRATION_ERROR", "VM_SERVER_BOOTUP_ERROR", "VM_CONNECTION_DATA", "VM_BOOT_FAILURE", "VM_SERVER_UNREGISTRATION_ERROR", "VM_SERVER_SHUTDOWN_ERROR", "DOMAIN_DESTRUCTION_ERROR", "VM_SERVER_CONFIGURATION_CHANGE_ERROR", "CONNECTION_ERROR", "COMMAND_TIMED_OUT") from clusterServer.networking.packets import MAIN_SERVER_PACKET_T as PACKET_T class CommandsHandler(object): """ Esta clase define métodos estáticos que serializan y deserializan comandos y salidas de comandos """ @staticmethod def createVMServerRegistrationCommand(vmServerIP, vmServerPort, vmServerName, isVanillaServer):
======================================================================== CygnusCloud ======================================================================== File: packet_t.py Version: 6.0 Description: virtual machine server packet types definition Copyright 2012-13 Luis Barrios Hernández, Adrián Fernández Hernández, Samuel Guayerbas Martín Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum VM_SERVER_PACKET_T = enum("CREATE_DOMAIN", "DESTROY_DOMAIN", "REBOOT_DOMAIN", "DOMAIN_CONNECTION_DATA", "SERVER_STATUS", "SERVER_STATUS_REQUEST", "USER_FRIENDLY_SHUTDOWN", "HALT", "QUERY_ACTIVE_VM_DATA", "ACTIVE_VM_DATA", "QUERY_ACTIVE_DOMAIN_UIDS", "ACTIVE_DOMAIN_UIDS", "IMAGE_EDITION", "IMAGE_EDITION_ERROR", "DEPLOY_IMAGE", "IMAGE_DEPLOYMENT_ERROR","DELETE_IMAGE", "IMAGE_DELETION_ERROR", "IMAGE_EDITED", "IMAGE_DEPLOYED", "IMAGE_DELETED", "INTERNAL_ERROR")
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum CLUSTER_SERVER_PACKET_T = enum( "REGISTER_VM_SERVER", "VM_SERVER_REGISTRATION_ERROR", "QUERY_VM_SERVERS_STATUS", "VM_SERVERS_STATUS_DATA", "QUERY_VM_DISTRIBUTION", "VM_DISTRIBUTION_DATA", "UNREGISTER_OR_SHUTDOWN_VM_SERVER", "BOOTUP_VM_SERVER", "VM_SERVER_BOOTUP_ERROR", "VM_BOOT_REQUEST", "VM_CONNECTION_DATA", "VM_BOOT_FAILURE", "HALT", "QUERY_ACTIVE_VM_VNC_DATA", "ACTIVE_VM_VNC_DATA", "COMMAND_EXECUTED", "VM_SERVER_SHUTDOWN_ERROR", "VM_SERVER_UNREGISTRATION_ERROR", "DOMAIN_DESTRUCTION", "DOMAIN_DESTRUCTION_ERROR", "VM_SERVER_CONFIGURATION_CHANGE", "VM_SERVER_CONFIGURATION_CHANGE_ERROR", "GET_IMAGE", "SET_IMAGE", "QUERY_REPOSITORY_STATUS", "REPOSITORY_STATUS", "DEPLOY_IMAGE", "IMAGE_DEPLOYMENT_ERROR", "IMAGE_DEPLOYED", "DELETE_IMAGE_FROM_SERVER", "DELETE_IMAGE_FROM_SERVER_ERROR", "IMAGE_DELETED", "CREATE_IMAGE", "IMAGE_CREATION_ERROR", "IMAGE_CREATED", "EDIT_IMAGE", "IMAGE_EDITION_ERROR", "DELETE_IMAGE_FROM_INFRASTRUCTURE", "DELETE_IMAGE_FROM_INFRASTRUCTURE_ERROR", "AUTO_DEPLOY", "AUTO_DEPLOY_ERROR", "VM_SERVER_INTERNAL_ERROR", "QUERY_VM_SERVERS_RESOURCE_USAGE", "VM_SERVERS_RESOURCE_USAGE", "DOMAIN_REBOOT", "DOMAIN_REBOOT_ERROR")
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum from connectionStatus import ConnectionStatus from protocols import CygnusCloudProtocolFactory from ccutils.dataStructures.multithreadingCounter import MultithreadingCounter """ Connection status enum type. """ CONNECTION_STATUS = enum("OPENING", "READY_WAIT", "READY", "CLOSING", "CLOSED", "ERROR", "RECONNECT") class Connection(object): """ This is the base class for all network connections. """ def __init__(self, useSSL, certificatesDirectory, port, transferQueue, incomingDataThread, callbackObject): """ Initializes the connection. Args: useSSL: if True, all the traffic will be protectd by SSLv4. If false, certificatesDirectory: the directory where the certificates are stored port: the port assigned to the connection. transferQueue: the incoming data transferQueue assigned to the connection incomingDataThread: the incoming data thread assigned to the connection callbackObject: the callback object assigned to the connection
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum MODE_T = enum("BOOT_DOMAIN", "CREATE_OR_EDIT_IMAGE", "DEPLOY_IMAGE") class LoadBalancer(object): ''' This class defines the interface common to all the load balancing algorithms. ''' def __init__(self, databaseConnector): ''' Initializes the load balancer's state Args: databaseConnector: a connector to the main server database ''' self._dbConnector = databaseConnector def assignVMServer(self, imageID, mode): '''
# -*- coding: utf8 -*- ''' ======================================================================== CygnusCloud ======================================================================== File: editionState_t.py Version: 1.0 Description: image edition state enum type Copyright 2012-13 Luis Barrios Hernández, Adrián Fernández Hernández, Samuel Guayerbas Martín Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum EDITION_STATE_T = enum("TRANSFER_TO_VM_SERVER", "VM_ON", "TRANSFER_TO_REPOSITORY", "CHANGES_NOT_APPLIED", "AUTO_DEPLOYMENT", "AUTO_DEPLOYMENT_ERROR", "NOT_EDITED")
# -*- coding: utf8 -*- ''' ======================================================================== CygnusCloud ======================================================================== File: spanishCodesTranslator.py Version: 5.0 Description: commands enum type Copyright 2012-13 Luis Barrios Hernández, Adrián Fernández Hernández, Samuel Guayerbas Martín Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum COMMAND_TYPE = enum("REGISTER_VM_SERVER", "UNREGISTER_OR_SHUTDOWN_VM_SERVER", "BOOTUP_VM_SERVER", "VM_BOOT_REQUEST", "HALT", "DESTROY_DOMAIN", "REBOOT_DOMAIN", "VM_SERVER_CONFIGURATION_CHANGE", "DEPLOY_IMAGE", "DELETE_IMAGE", "CREATE_IMAGE", "EDIT_IMAGE", "DELETE_IMAGE_FROM_INFRASTRUCTURE", "AUTO_DEPLOY_IMAGE")
# -*- coding: utf8 -*- ''' ======================================================================== CygnusCloud ======================================================================== File: image_state_t.py Version: 1.0 Description: image state enum type Copyright 2012-13 Luis Barrios Hernández, Adrián Fernández Hernández, Samuel Guayerbas Martín Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum IMAGE_STATE_T = enum("READY", "EDITED", "DEPLOY", "DELETE")
# -*- coding: utf8 -*- ''' Gestor de paquetes del servidor de cluster @author: Luis Barrios Hernández @version: 4.0 ''' from ccutils.enums import enum CLUSTER_SERVER_PACKET_T = enum("REGISTER_VM_SERVER", "VM_SERVER_REGISTRATION_ERROR", "QUERY_VM_SERVERS_STATUS", "VM_SERVERS_STATUS_DATA", "QUERY_VM_DISTRIBUTION", "VM_DISTRIBUTION_DATA", "UNREGISTER_OR_SHUTDOWN_VM_SERVER", "BOOTUP_VM_SERVER", "VM_SERVER_BOOTUP_ERROR", "VM_BOOT_REQUEST", "VM_CONNECTION_DATA", "VM_BOOT_FAILURE", "HALT", "QUERY_ACTIVE_VM_DATA", "ACTIVE_VM_DATA", "COMMAND_EXECUTED", "VM_SERVER_SHUTDOWN_ERROR", "VM_SERVER_UNREGISTRATION_ERROR", "DOMAIN_DESTRUCTION", "DOMAIN_DESTRUCTION_ERROR", "VM_SERVER_CONFIGURATION_CHANGE", "VM_SERVER_CONFIGURATION_CHANGE_ERROR", "GET_IMAGE", "SET_IMAGE", "QUERY_REPOSITORY_STATUS", "REPOSITORY_STATUS", "DEPLOY_IMAGE", "IMAGE_DEPLOYMENT_ERROR", "IMAGE_DEPLOYED", "DELETE_IMAGE_FROM_SERVER", "DELETE_IMAGE_FROM_SERVER_ERROR", "IMAGE_DELETED", "CREATE_IMAGE", "IMAGE_CREATION_ERROR", "IMAGE_CREATED", "EDIT_IMAGE", "IMAGE_EDITION_ERROR", "DELETE_IMAGE_FROM_INFRASTRUCTURE", "DELETE_IMAGE_FROM_INFRASTRUCTURE_ERROR", "AUTO_DEPLOY", "AUTO_DEPLOY_ERROR", "VM_SERVER_INTERNAL_ERROR", "QUERY_VM_SERVERS_RESOURCE_USAGE", "VM_SERVERS_RESOURCE_USAGE") class ClusterServerPacketHandler(object): """ Estos objetos leen y escriben los paquetes que el endpoint y el servidor de cluster utilizan para comunicarse. """ def __init__(self, packetCreator): """ Inicializa el estado del gestor de paquetes Argumentos:
# -*- coding: utf8 -*- ''' ======================================================================== CygnusCloud ======================================================================== File: transfer_t.py Version: 2.0 Description: transfer enum type Copyright 2012-13 Luis Barrios Hernández, Adrián Fernández Hernández, Samuel Guayerbas Martín Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum TRANSFER_T = enum("CREATE_IMAGE", "EDIT_IMAGE", "DEPLOY_IMAGE", "STORE_IMAGE", "CANCEL_EDITION")
# -*- coding: utf8 -*- ''' ======================================================================== CygnusCloud ======================================================================== File: image_status.py Version: 1.0 Description: image status enum type Copyright 2012-13 Luis Barrios Hernández, Adrián Fernández Hernández, Samuel Guayerbas Martín Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum IMAGE_STATUS_T = enum("NOT_RECEIVED", "READY", "EDITION")
# -*- coding: utf8 -*- """ ======================================================================== CygnusCloud ======================================================================== File: image_state_t.py Version: 1.0 Description: image state enum type Copyright 2012-13 Luis Barrios Hernández, Adrián Fernández Hernández, Samuel Guayerbas Martín Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from ccutils.enums import enum IMAGE_STATE_T = enum("READY", "EDITED", "DEPLOY", "DELETE")
File: spanishCodesTranslator.py Version: 5.0 Description: command outputs enum type Copyright 2012-13 Luis Barrios Hernández, Adrián Fernández Hernández, Samuel Guayerbas Martín Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum COMMAND_OUTPUT_TYPE = enum("VM_SERVER_REGISTRATION_ERROR", "VM_SERVER_BOOTUP_ERROR", "VM_CONNECTION_DATA", "VM_BOOT_FAILURE", "VM_SERVER_UNREGISTRATION_ERROR", "VM_SERVER_SHUTDOWN_ERROR", "DOMAIN_DESTRUCTION_ERROR", "DOMAIN_REBOOT_ERROR", "VM_SERVER_CONFIGURATION_CHANGE_ERROR", "CONNECTION_ERROR", "COMMAND_TIMED_OUT", "IMAGE_DEPLOYMENT_ERROR", "DELETE_IMAGE_FROM_SERVER_ERROR", "IMAGE_CREATION_ERROR", "IMAGE_EDITION_ERROR", "DELETE_IMAGE_FROM_INFRASTRUCTURE_ERROR", "AUTO_DEPLOY_ERROR", "VM_SERVER_INTERNAL_ERROR", "IMAGE_DEPLOYED", "IMAGE_CREATED", "IMAGE_EDITED", "IMAGE_DELETED")
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from connection import Connection, CONNECTION_STATUS from ccutils.enums import enum from twisted.internet import reactor, ssl from twisted.internet.endpoints import TCP4ClientEndpoint, SSL4ClientEndpoint from network.exceptions.connection import ConnectionException from time import sleep """ Reconnection status enum type """ RECONNECTION_T = enum("RECONNECTING", "REESTABLISHED", "TIMED_OUT") class ClientConnection (Connection) : """ These objects represent client connections """ def __init__(self, useSSL, certificatesDirectory, host, port, transferQueue, incomingDataThread, reconnect, callbackObject): """ Initializes the connection's state Args: useSSL: if True, all the traffic will be protectd by SSLv4. If false, certificatesDirectory: the directory where the certificates are stored host: the server's hostname or IPv4 address port: the port assigned to the connection. transferQueue: the incoming data transferQueue assigned to the connection
ERROR_DESC_T = enum ("IR_IMAGE_DELETED", # The image was deleted from the image repository "IR_UNKNOWN_IMAGE", # The image does not exist in the image repository "IR_IMAGE_EDITED", # Someone is already editing the image "IR_NOT_EDITED_IMAGE", # The image is not being edited. Therefore, an updated copy of it cannot be uploaded to the image repository. "VMSRVR_INTERNAL_ERROR", # Internal error at a virtual machine server "VMSRVR_UNKNOWN_IMAGE", # The image is not deployed at the virtual machine server. "VMSRVR_LOCKED_IMAGE", # The image is being edited, so it can't be deleted. "VMSRVR_COMPRESSION_ERROR", # Unable to extract or create a .zip file at a virtual machine server. "VMSRVR_IR_CONNECTION_ERROR", # The virtual machine server cannot connect to the image repository. "VMSRVR_RETR_TRANSFER_ERROR", # The FTP RETR transfer crashed. "VMSRVR_STOR_TRANSFER_ERROR", # The FTP STOR transfer crashed. "CLSRVR_NOT_EDITED_IMAGE", # The image is not being edited, "CLSRVR_AUTODEPLOYED", # The automatic deployment of the image has already begun. "CLSRVR_AUTOD_TOO_MANY_INSTANCES", # The automatic deployment process cannot create the required instance number. "CLSRVR_LOCKED_IMAGE", # The image is already being edited, so it can't be deleted. "CLSRVR_DELETED_IMAGE", # The image is already being deleted, so it can't be deleted. "CLSRVR_UNKNOWN_IMAGE", # The image is not registered at the cluster server. "CLSRVR_IR_CONNECTION_ERROR", # The cluster server cannot connect to the image repository. "CLSRVR_IR_NO_DISK_SPACE", # There's not enough disk space at the image repository. "CLSRVR_UNKNOWN_VMSRVR", # The requested virtual machine server is not registered. "CLSRVR_VMSRVR_NOT_READY", # The requested virtual machine server is not ready yet. "CLSRVR_IMAGE_HOSTED_ON_VMSRVR", # The requested virtual machine server already stores the image. "CLSRVR_IMAGE_NOT_HOSTED_ON_VMSRVR", # The requested virtual machine server does not store the image. "CLSRVR_VMSRVR_NO_DISK_SPACE", # There's not enough disk space at the requested virtual machine server. "CLSRVR_VMSRVR_CONNECTION_ERROR", # The connnection with the requested virtual machine server cannot be established. "CLSRVR_VMSRVR_CONNECTION_LOST", # The connnection with the requested virtual machine server was lost. "CLSRVR_DOMAIN_NOT_REGISTERED", # The virtual machine is not registered on the cluster server. "CLSRVR_ACTIVE_VMSRVR", # The requested virtual machine server is already on. Therefore, its basic configuration cannot be changed. "CLSRVR_VMSRVR_IDS_IN_USE", # The virtual machine server's new name or IP address are already in use. "CLSRVR_AUTOD_ERROR", # The auto deployment operation crashed on several virtual machine servers., "CLSRVR_VM_BOOT_TIMEOUT", # Timeout error on virtual machine boot "CLSRVR_IMAGE_NOT_AVAILABLE", # The requested image is not available "CLSRVR_NO_EDITION_SRVRS", # There are no edition servers to create or edit the image. "CLSRVR_NO_CANDIDATE_SRVRS", # There are no candidate servers to deploy an image. "CLSRVR_EDITION_VMSRVRS_UNDER_FULL_LOAD", # There are not enough edition servers to perform the requested operation. "CLSRVR_VMSRVRS_UNDER_FULL_LOAD", # There are not enough virtual machine servers to perform the requested operation. )
See the License for the specific language governing permissions and limitations under the License. """ from ccutils.enums import enum COMMAND_OUTPUT_TYPE = enum( "VM_SERVER_REGISTRATION_ERROR", "VM_SERVER_BOOTUP_ERROR", "VM_CONNECTION_DATA", "VM_BOOT_FAILURE", "VM_SERVER_UNREGISTRATION_ERROR", "VM_SERVER_SHUTDOWN_ERROR", "DOMAIN_DESTRUCTION_ERROR", "DOMAIN_REBOOT_ERROR", "VM_SERVER_CONFIGURATION_CHANGE_ERROR", "CONNECTION_ERROR", "COMMAND_TIMED_OUT", "IMAGE_DEPLOYMENT_ERROR", "DELETE_IMAGE_FROM_SERVER_ERROR", "IMAGE_CREATION_ERROR", "IMAGE_EDITION_ERROR", "DELETE_IMAGE_FROM_INFRASTRUCTURE_ERROR", "AUTO_DEPLOY_ERROR", "VM_SERVER_INTERNAL_ERROR", "IMAGE_DEPLOYED", "IMAGE_CREATED", "IMAGE_EDITED", "IMAGE_DELETED", )
======================================================================== File: packet_t.py Version: 2.0 Description: image repository packet types definition Copyright 2012-13 Luis Barrios Hernández, Adrián Fernández Hernández, Samuel Guayerbas Martín Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum PACKET_T = enum("HALT", "ADD_IMAGE", "ADDED_IMAGE_ID", "RETR_REQUEST", "RETR_REQUEST_RECVD", "RETR_REQUEST_ERROR", "RETR_START", "RETR_ERROR", "STOR_REQUEST", "STOR_REQUEST_RECVD", "STOR_REQUEST_ERROR", "STOR_START", "STOR_ERROR", "DELETE_REQUEST", "DELETE_REQUEST_RECVD", "DELETE_REQUEST_ERROR", "STATUS_REQUEST", "STATUS_DATA", "CANCEL_EDITION", "IMAGE_EDITION_CANCELLED")
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from connection import Connection, CONNECTION_STATUS from ccutils.enums import enum from twisted.internet import reactor, ssl from twisted.internet.endpoints import TCP4ClientEndpoint, SSL4ClientEndpoint from network.exceptions.connection import ConnectionException from time import sleep """ Reconnection status enum type """ RECONNECTION_T = enum("RECONNECTING", "REESTABLISHED", "TIMED_OUT") class ClientConnection(Connection): """ These objects represent client connections """ def __init__(self, useSSL, certificatesDirectory, host, port, transferQueue, incomingDataThread, reconnect, callbackObject): """ Initializes the connection's state Args: useSSL: if True, all the traffic will be protectd by SSLv4. If false, certificatesDirectory: the directory where the certificates are stored host: the server's hostname or IPv4 address port: the port assigned to the connection.
# -*- coding: UTF8 -*- ''' Command handler class definition. @author: Luis Barrios Hernández @version: 1.0 ''' from ccutils.enums import enum COMMAND_TYPE = enum("REGISTER_VM_SERVER", "UNREGISTER_OR_SHUTDOWN_VM_SERVER", "BOOTUP_VM_SERVER", "VM_BOOT_REQUEST", "HALT") COMMAND_OUTPUT_TYPE = enum("VM_SERVER_REGISTRATION_ERROR", "VM_SERVER_BOOTUP_ERROR", "VM_CONNECTION_DATA", "VM_BOOT_FAILURE", "VM_SERVER_UNREGISTRATION_ERROR", "VM_SERVER_SHUTDOWN_ERROR") from clusterServer.networking.packets import MAIN_SERVER_PACKET_T as PACKET_T class CommandsHandler(object): """ This class provides methods to serialize and deserialize commands and command outputs. """ @staticmethod def createVMServerRegistrationCommand(vmServerIP, vmServerPort, vmServerName): """ Creates a virtual machine server registration command Args: vmServerIP: the virtual machine server's IPv4 address vmServerPort: the virtual machine server's listenning port vmServerName: the virtual machine server's name.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum MODE_T = enum("BOOT_DOMAIN", "CREATE_OR_EDIT_IMAGE", "DEPLOY_IMAGE") class LoadBalancer(object): ''' This class defines the interface common to all the load balancing algorithms. ''' def __init__(self, databaseConnector): ''' Initializes the load balancer's state Args: databaseConnector: a connector to the main server database ''' self._dbConnector = databaseConnector def assignVMServer(self, imageID, mode):
ERROR_DESC_T = enum( "IR_IMAGE_DELETED", # The image was deleted from the image repository "IR_UNKNOWN_IMAGE", # The image does not exist in the image repository "IR_IMAGE_EDITED", # Someone is already editing the image "IR_NOT_EDITED_IMAGE", # The image is not being edited. Therefore, an updated copy of it cannot be uploaded to the image repository. "VMSRVR_INTERNAL_ERROR", # Internal error at a virtual machine server "VMSRVR_UNKNOWN_IMAGE", # The image is not deployed at the virtual machine server. "VMSRVR_LOCKED_IMAGE", # The image is being edited, so it can't be deleted. "VMSRVR_COMPRESSION_ERROR", # Unable to extract or create a .zip file at a virtual machine server. "VMSRVR_IR_CONNECTION_ERROR", # The virtual machine server cannot connect to the image repository. "VMSRVR_RETR_TRANSFER_ERROR", # The FTP RETR transfer crashed. "VMSRVR_STOR_TRANSFER_ERROR", # The FTP STOR transfer crashed. "CLSRVR_NOT_EDITED_IMAGE", # The image is not being edited, "CLSRVR_AUTODEPLOYED", # The automatic deployment of the image has already begun. "CLSRVR_AUTOD_TOO_MANY_INSTANCES", # The automatic deployment process cannot create the required instance number. "CLSRVR_LOCKED_IMAGE", # The image is already being edited, so it can't be deleted. "CLSRVR_DELETED_IMAGE", # The image is already being deleted, so it can't be deleted. "CLSRVR_UNKNOWN_IMAGE", # The image is not registered at the cluster server. "CLSRVR_IR_CONNECTION_ERROR", # The cluster server cannot connect to the image repository. "CLSRVR_IR_NO_DISK_SPACE", # There's not enough disk space at the image repository. "CLSRVR_UNKNOWN_VMSRVR", # The requested virtual machine server is not registered. "CLSRVR_VMSRVR_NOT_READY", # The requested virtual machine server is not ready yet. "CLSRVR_IMAGE_HOSTED_ON_VMSRVR", # The requested virtual machine server already stores the image. "CLSRVR_IMAGE_NOT_HOSTED_ON_VMSRVR", # The requested virtual machine server does not store the image. "CLSRVR_VMSRVR_NO_DISK_SPACE", # There's not enough disk space at the requested virtual machine server. "CLSRVR_VMSRVR_CONNECTION_ERROR", # The connnection with the requested virtual machine server cannot be established. "CLSRVR_VMSRVR_CONNECTION_LOST", # The connnection with the requested virtual machine server was lost. "CLSRVR_DOMAIN_NOT_REGISTERED", # The virtual machine is not registered on the cluster server. "CLSRVR_ACTIVE_VMSRVR", # The requested virtual machine server is already on. Therefore, its basic configuration cannot be changed. "CLSRVR_VMSRVR_IDS_IN_USE", # The virtual machine server's new name or IP address are already in use. "CLSRVR_AUTOD_ERROR", # The auto deployment operation crashed on several virtual machine servers., "CLSRVR_VM_BOOT_TIMEOUT", # Timeout error on virtual machine boot "CLSRVR_IMAGE_NOT_AVAILABLE", # The requested image is not available "CLSRVR_NO_EDITION_SRVRS", # There are no edition servers to create or edit the image. "CLSRVR_NO_CANDIDATE_SRVRS", # There are no candidate servers to deploy an image. "CLSRVR_EDITION_VMSRVRS_UNDER_FULL_LOAD", # There are not enough edition servers to perform the requested operation. "CLSRVR_VMSRVRS_UNDER_FULL_LOAD", # There are not enough virtual machine servers to perform the requested operation. )
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' from ccutils.enums import enum from connectionStatus import ConnectionStatus from protocols import CygnusCloudProtocolFactory from ccutils.dataStructures.multithreadingCounter import MultithreadingCounter """ Connection status enum type. """ CONNECTION_STATUS = enum("OPENING", "READY_WAIT", "READY", "CLOSING", "CLOSED", "ERROR", "RECONNECT") class Connection(object): """ This is the base class for all network connections. """ def __init__(self, useSSL, certificatesDirectory, port, transferQueue, incomingDataThread, callbackObject): """ Initializes the connection. Args: useSSL: if True, all the traffic will be protectd by SSLv4. If false, certificatesDirectory: the directory where the certificates are stored port: the port assigned to the connection. transferQueue: the incoming data transferQueue assigned to the connection
# -*- coding: UTF8 -*- from ccutils.enums import enum from database.utils.connector import BasicDatabaseConnector import time SERVER_STATE_T = enum("BOOTING", "READY", "SHUT_DOWN", "RECONNECTING", "CONNECTION_TIMED_OUT") IMAGE_STATE_T = enum("READY", "EDITED", "DEPLOY", "DELETE") class ClusterServerDatabaseConnector(BasicDatabaseConnector): """ Nota: esta clase es ServerVMManager, con los métodos específicos de ImagesInServerManager. """ ''' These objects register and delete virtual machine servers to the database. ''' def __init__(self, sqlUser, sqlPassword, databaseName): ''' Constructor de la clase. Recibe el nombre y lla contrasennia del usuario sql encargado de gestionar la base de datos Argumentos: sqlUser: usuario para conectarnos a MySQL sqlPassword: contraseña para conectarnos a MySQL databaseName: nombre de la base de datos a la que nos vamos a conectar Devuelve: Nada '''
# -*- coding: UTF8 -*- ''' Definiciones del gestor de comandos @author: Luis Barrios Hernández @version: 1.5 ''' from ccutils.enums import enum COMMAND_TYPE = enum("REGISTER_VM_SERVER", "UNREGISTER_OR_SHUTDOWN_VM_SERVER", "BOOTUP_VM_SERVER", "VM_BOOT_REQUEST", "HALT", "DESTROY_DOMAIN", "VM_SERVER_CONFIGURATION_CHANGE") COMMAND_OUTPUT_TYPE = enum("VM_SERVER_REGISTRATION_ERROR", "VM_SERVER_BOOTUP_ERROR", "VM_CONNECTION_DATA", "VM_BOOT_FAILURE", "VM_SERVER_UNREGISTRATION_ERROR", "VM_SERVER_SHUTDOWN_ERROR", "DOMAIN_DESTRUCTION_ERROR", "VM_SERVER_CONFIGURATION_CHANGE_ERROR", "CONNECTION_ERROR", "COMMAND_TIMED_OUT") from clusterServer.networking.packets import MAIN_SERVER_PACKET_T as PACKET_T class CommandsHandler(object): """ Esta clase define métodos estáticos que serializan y deserializan comandos y salidas de comandos """ @staticmethod def createVMServerRegistrationCommand(vmServerIP, vmServerPort, vmServerName, isVanillaServer): """ Crea un comando de registro de un servidor de máquinas virtuales Args: vmServerIP: la IP del servidor vmServerPort: el puerto en el que escucha
# -*- coding: UTF8 -*- from ccutils.enums import enum from database.utils.connector import BasicDatabaseConnector import time SERVER_STATE_T = enum("BOOTING", "READY", "SHUT_DOWN", "RECONNECTING", "CONNECTION_TIMED_OUT") IMAGE_STATE_T = enum("READY", "EDITED", "DEPLOY", "DELETE") class ClusterServerDatabaseConnector(BasicDatabaseConnector): """ Nota: esta clase es ServerVMManager, con los métodos específicos de ImagesInServerManager. """ ''' These objects register and delete virtual machine servers to the database. ''' def __init__(self, sqlUser, sqlPassword, databaseName): ''' Constructor de la clase. Recibe el nombre y lla contrasennia del usuario sql encargado de gestionar la base de datos Argumentos: sqlUser: usuario para conectarnos a MySQL sqlPassword: contraseña para conectarnos a MySQL databaseName: nombre de la base de datos a la que nos vamos a conectar Devuelve: Nada ''' BasicDatabaseConnector.__init__(self, sqlUser, sqlPassword, databaseName)