fog05.interfaces package

Submodules

fog05.interfaces.Agent module

class fog05.interfaces.Agent.Agent(uuid)

Bases: object

get_network_plugin(cnetwork_uuid)
get_os_plugin()
get_runtime_plugin(runtime_uuid)
list_network_plugins()
list_runtime_plugins()
refresh_plugins()

fog05.interfaces.Entity module

class fog05.interfaces.Entity.Entity

Bases: object

add_instance(instance_object)
after_migrate()
before_migrate()
get_instance(instance_uuid)
get_state()
has_instance(instance_uuid)
on_clean()
on_configured(configuration)
on_defined()
on_pause()
on_resume()
on_start()
on_stop()
remove_instance(instance_object)
set_state(state)

fog05.interfaces.EntityInstance module

class fog05.interfaces.EntityInstance.EntityInstance(uuid, entity_uuid)

Bases: object

after_migrate()
before_migrate()
get_state()
on_clean()
on_configured(configuration)
on_pause()
on_resume()
on_start()
on_stop()
set_state(state)

fog05.interfaces.MonitoringPlugin module

class fog05.interfaces.MonitoringPlugin.MonitoringPlugin(version, plugin_uuid=None)

Bases: fog05.interfaces.Plugin.Plugin

start_monitoring()

start the runtime :return: runtime pid or runtime uuid?

stop_monitoring()

stop this runtime

fog05.interfaces.NetworkPlugin module

exception fog05.interfaces.NetworkPlugin.BridgeAssociatedToNetworkException(message, errors)

Bases: Exception

exception fog05.interfaces.NetworkPlugin.BridgeNotExistingException(message, errors)

Bases: Exception

exception fog05.interfaces.NetworkPlugin.InterfaceNotExistingException(message, errors)

Bases: Exception

exception fog05.interfaces.NetworkPlugin.InterfaceNotInNetworkException(message, errors)

Bases: Exception

exception fog05.interfaces.NetworkPlugin.NetworkAlreadyExistsException(message, errors)

Bases: Exception

exception fog05.interfaces.NetworkPlugin.NetworkHasPendingInterfacesException(message, errors)

Bases: Exception

class fog05.interfaces.NetworkPlugin.NetworkPlugin(version, plugin_uuid)

Bases: fog05.interfaces.Plugin.Plugin

Class: NetworkPlugin

This class is an interface for plugins that control the network resouces, and provide an abstraction layer for networking managment functions

allocate_bandwidth(intf_uuid, bandwidth)

This should allocate bandwidth to a certaint virtual interface, if the interface not exists throw an exception

Intf_uuid:String
Bandwidth:tuple (up,down)
Returns:bool
assign_interface_to_network(network_uuid, intf_uuid)

This should assign the interface identified by intf_uuid to the network identified by network_uuid, if the interface not exists throw an exception

Network_uuid:String
Intf_uuid:String
Returns:bool
create_connection_point(cp_uuid)

Create a connection point with the given uuid

ip tuntap add dev tun0 mode tun

ip tuntap add dev tap0-1 mode tap

attach one to the atomic entity and the other will be the connection point

DEVICE TYPE FOR IP2ROUTE
TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap | bridge | bond | ipoib | ip6tnl | ipip | sit | vxlan | gre | gretap | ip6gre | ip6gretap | vti | nlmon | bond_slave | ipvlan | geneve | bridge_slave | vrf }
Parameters:cp_uuid
Returns:the name of the connection point (the connection point is a virtual interface like a vtap interface)
create_virtual_bridge(name, uuid)

This should create a virtual bridge

Name:String
Returns:tuple (bridge_name,bridge_uuid) or None in case of failure
create_virtual_interface(name, uuid)

This should create a virtual network interface

Name:String
Returns:tuple (interface_name,interface_uuid) or None in case of failure

Create a virtual link between 2 connection points

eg if is a linux bridge

sudo ip link add vl_name type bridge sudo ip link set cp_1 master bridge_name sudo ip link set cp_2 master bridge_name

Parameters:
  • vl_uuid – string uuid of the new virtual link
  • connection_points – list of 2 connection point uuid
Returns:

the virtual name (vl is a linux bridge or a openvswitch with only 2 ports)

create_virtual_network(network_name, uuid, ip_range, has_dhcp, gateway, manifest)

This should create a virtual network, with given caratteristics

range should specified as CIRD subnet eg. 192.168.0.0/24 which means from 192.168.0.1 to 192.168.0.254 if gateway address is none the entities connected to that network cannot reach internet if dhcp is true the easiest way to have a dhcp server is using dnsmasq eg. sudo dnsmasq -d –interface=<bridge_associated_to_this_network> –bind-interfaces –dhcp-range=<start_ip>,<end_ip> using -d you can parse dnsmasq output to listen to events like dhcp ack

Network_name:String
Ip_range:String
Has_dhcp:bool
Gateway:String
Returns:tuple (net_name,net_uuid) or None in case of failure

#TODO on fog05 -> support dhcp as used on OSM

delete_virtual_bridge(br_uuid)

Delete a virtual bride, if the bridge is one assigned to a network should throw an exception, if the bridge not exists throw an exception

Br_uuid:String
Returns:bool
delete_virtual_interface(intf_uuid)

This should delete a virtual interface identified by intf_uuid, if the interface is assigned to a network maybe can also call removeInterfaceFromNetwork() to avoid any problem, if the interface not exists throw an exception

Intf_uuid:String
Returns:bool
delete_virtual_network(network_uuid)

Delete the virtual network network_uuid, for correct network shutdown should kill the dnsmasq process eventually associated for dhcp and remove the bridge, if there are interface associate to this network should throw an exception

Network_uuid:String
Returns:bool
get_network_info(network_uuid)
remove_interface_from_network(network_uuid, intf_uuid)

Remove the interface intf_uuid from network network_uuid, if interface not present throw an exception

Network_uuid:String
Intf_uuid:String
Returns:bool
stop_network()

fog05.interfaces.OSPlugin module

exception fog05.interfaces.OSPlugin.FileNotExistingException(message, errors)

Bases: Exception

class fog05.interfaces.OSPlugin.OSPlugin(version, plugin_uuid=None)

Bases: fog05.interfaces.Plugin.Plugin

Interfaces for plugins that allow interaction with underlying operating system provide an abstraction layer for some managment and monitoring functions

add_know_host(hostname, ip)
check_if_pid_exists(pid)
create_dir(path)
create_file(path)
dir_exists(path)
download_file(url, file_path)
execute_command(command, blocking)

Execute a command to cli of underlying os, IDK should return bool or the command output?

Command:String
Returns:String or bool?
file_exists(file_path)
get_CPUID()

Return the underlying hw cpuid :return: String

get_CPU_level()

Return the current cpu usage level :return: float

get_accelerators_informations()
get_base_path()
get_disks_information()
get_hostname()
get_intf_type(name)
get_io_informations()
get_memory_information()
get_memory_level()

Return the current memory usage level :return: float

get_network_informations()
get_network_level()

Return the current network usage level :return: float

get_pid(process)

Try to get the the pid from the process name :process: string :return: int

get_position_information()
get_processor_information()
get_storage_level()

Return the current local storage usage level :return: float

get_uuid()
install_package(packages)

Install all packages passed within the parameter, return a bool to know the retult of operation

Packages:tuple
Returns:bool
read_binary_file(file_path)
read_file(file_path, root=False)

Read the content from a file in the local disk, maybe can convert from windows dir separator to unix dir separator return the file content throw an exception if file not exits

File_path:String
Returns:byte
remove_dir(path)
remove_file(path)
remove_know_host(hostname)
remove_package(packages)

Remove all packages passed within the parameter, return a bool to know the retult of operation

Packages:tuple
Returns:bool
send_sig_int(pid)

Send a SigKill (Ctrl+C) to the process identified by pid throw an exception if pid not exits :pid: int :return: bool

send_sig_kill(pid)

Send a SigKill (kill the process) to the process identified by pid throw an exception if pid not exits :pid: int :return: bool

send_signal(signal, pid)

Send a signal to the process identified by pid throw an exception if pid not exits

Signal:int
Pid:int
Returns:bool
set_accelerator_available(acc_name)
set_accelerator_unaviable(acc_name)
set_interface_available(intf_name)
set_interface_unaviable(intf_name)
set_io_available(io_name)
set_io_unaviable(io_name)
store_file(content, file_path, filename)

Store a file in local disk, maybe can convert from windows dir separator to unix dir separator

Content:byte
File_path:string
Filename:string
Returns:bool
exception fog05.interfaces.OSPlugin.ProcessNotExistingException(message, errors)

Bases: Exception

fog05.interfaces.Plugin module

class fog05.interfaces.Plugin.Plugin(version, plugin_uuid=None)

Bases: object

get_version()
react_to_cache(key, value, version)

fog05.interfaces.ResourceManagmentPlugin module

fog05.interfaces.RuntimePlugin module

exception fog05.interfaces.RuntimePlugin.EntityNotExistingException(message, errors)

Bases: Exception

exception fog05.interfaces.RuntimePlugin.MigrationNotAllowedException(message, errors)

Bases: Exception

exception fog05.interfaces.RuntimePlugin.MigrationNotPossibleException(message, errors)

Bases: Exception

class fog05.interfaces.RuntimePlugin.RuntimePlugin(version, plugin_uuid=None)

Bases: fog05.interfaces.Plugin.Plugin

after_migrate_entity_actions(entity_uuid, dst=False, instance_uuid=None)

Action to be taken after a migration eg. delete disks of vms, delete state of µSvc, undefine entity

Entity_uuid:String
Returns:bool
before_migrate_entity_actions(entity_uuid, dst=False, instance_uuid=None)

Action to be taken before a migration eg. copy disks of vms, save state of µSvc

Entity_uuid:String
Returns:bool
clean_entity(entity_uuid, instance_uuid=None)

Clean an entity

this mode destroy the entity instance

if the entity state do not allow transition to DEFINED (in this case is not in CONFIGURED) should throw an exception

Entity_uuid:String
Returns:bool
configure_entity(entity_uuid, instance_uuid=None)

Configure an entity

This should create an entity instance that can be addressed by …/entity/<entity_uuid>/instance/<instance_uuid> not clear at the time if instance uuid should be generated by this method or came as a paramenter This state is the separation from entity and entity instances, because here we create the files

if the entity state do not allow transition to CONFIGURED (in this case is not in DEFINED) should throw an exception

Entity_uuid:String
Returns:bool
define_entity(*args, **kwargs)

Define entity from args of from manifest file passed within parameters return the entity uuid :args: dict :return: String

get_entities()
is_uuid(uuid_string)
migrate_entity(entity_uuid, dst=False, instance_uuid=None)

Migrate the entity identified by entity_uuid to the new FogNode identified by fognode_uuid The migration depend to the nature of the entity (native app, µSvc, VM, Container) if the entity state do not allow transition to MIGRATE (eg a native app can’t be migrated) should throw an exception if the destination node can’t handle the migration an exception should be throwed

To help migration should use the two methods:

  • beforeMigrateEntityActions()
  • afterMigrateEntiryActions()

After the migration the entity on the source node has to be undefined the one on the destination node has to be in RUNNING

Entity_uuid:String
Fognode_uuid:String
Returns:bool
pause_entity(entity_uuid, instance_uuid=None)

Pause an entity

if the entity state do not allow transition to PAUSED (in this case is not in RUNNING) should throw an exception

Entity_uuid:String
Returns:bool
resume_entity(entity_uuid, instance_uuid=None)

Resume an entity

if the entity state do not allow transition to RUNNING (in this case is not in PAUSED) should throw an exception

Entity_uuid:String
Returns:bool
run_entity(enitity_uuid, instance_uuid=None)

Start the entity identified by entity_uuid if the entity state do not allow transition to RUN (eg is non CONFIGURED) should throw an exception

Entity_uuid:String
Returns:bool
scale_entity(entity_uuid, instance_uuid=None)

Scale an entity eg. give more cpu/ram/disk, maybe passed by parameter the new scale value?

if the entity state do not allow transition to SCALE (in this case is not in RUNNING) should throw an exception

Entity_uuid:String
Returns:bool
start_runtime()

start the runtime :return: runtime pid or runtime uuid?

stop_entity(enitity_uuid, instance_uuid=None)

Stop the entity identified by entity_uuid if the entity state do not allow transition to CONFIGURED (in this case is not in RUNNING) should throw an exception

Entity_uuid:String
Returns:bool
stop_runtime()

stop this runtime

undefine_entity(enitity_uuid)

Undefine the entity identified by entity_uuid if the entity state do not allow transition to UNDEFINED should throw an exception

Entity_uuid:String
Returns:bool
exception fog05.interfaces.RuntimePlugin.StateTransitionNotAllowedException(message, errors)

Bases: Exception

fog05.interfaces.States module

class fog05.interfaces.States.State

Bases: enum.Enum

States of entities

CONFIGURED = 3
DEFINED = 1
ERROR = -1
LANDING = 9
MIGRATING = 7
PAUSED = 5
RUNNING = 4
SCALING = 6
TAKING_OFF = 8
UNDEFINED = 0

Module contents