Example #1
0
    def send_pod_info(self, pod: Pod):
        if not self.has_changed(pod):
            return

        if not pod.is_error():
            return

        self.send_message(pod.message_title(), pod.message_content())
Example #2
0
    def has_changed(self, status: Pod):
        identifier = status.identifier()
        if identifier not in self.cache:
            self.cache[identifier] = Cache(status.status_value())
            return True

        cache = self.cache[identifier]

        if cache.value != status.status_value():
            self.cache[identifier] = Cache(status.status_value())
            return True
        else:
            cache.ttl = cache.ttl + 1

        return False
Example #3
0
def init_aggregator(aggregator, content):
    for element in content['plants']:
        vars()[element['name']] = Pod(name=element['name'])
        # if element['type'] == 'MIX':
        for c in element['components']:
            profile = load_profile(c)
            if profile != None:
                vars()[element['name']].add_profile(profile)
        # else:
        #    profile = load_profile(element)
        #    if profile != None:
        #        vars()[element['name']].add_profile(profile)

        aggregator.add_pod(vars()[element['name']])
Example #4
0
 def CreatePod(self, deployment):
     podName = deployment.deploymentLabel + "_" + str(
         self.GeneratePodName())
     pod = Pod(podName, deployment.cpuCost, deployment.deploymentLabel)
     #print("Pod " + pod.podName + " created")
     self.etcd.pendingPodList.append(pod)
Example #5
0
                     '.uvax.27.plants.1051.profile.baseline.npy')
bess2_test = np.load('Baseline/' + date +
                     '.uvax.27.plants.1052.profile.baseline.npy')
chp1_test = np.load('Baseline/' + date +
                    '.uvax.27.plants.1054.profile.baseline.npy')

plot_tests = False
########################################################################################
#
#      SINGLE ELEMENT PODs
#
########################################################################################
# PV
pv1 = PV(pv1_test)  # max(kW) = 10 - day: center
pv2 = PV(pv2_test)  # max(kW) = 20 - day: center
p_pv1 = Pod(pv1)
p_pv2 = Pod(pv2)

# WIND
wind1 = Wind(wind1_test)  # max(kW) = 0.4 - day: center
wind2 = Wind(wind2_test)  # max(kW) = 0.8 - day: left
p_wind1 = Pod(wind1)
p_wind2 = Pod(wind2)
# CHP
chp1 = CHP(chp1_test,
           [x for x in list(range(0, 96)) if x not in list(range(0, 20))
            ])  # max(kW) = 0.8 - day: center
p_chp1 = Pod(pv1)
# print_graph(chp1)

# BESS
Example #6
0
from src.api_server import APIServer
from src.load_balancer import LoadBalancer
from src.hpa import HPA
from src.pod import Pod
import unittest

DEPLOYMENT_INFO = ['Deployment_AA', 2, 2]
HPA_INFO = ['Deployment_AA', 75, 10, 5]
_hpaCtlLoop = 2

apiServer = APIServer()
apiServer.CreateDeployment(DEPLOYMENT_INFO)
deployment = apiServer.etcd.deploymentList[0]

podName = deployment.deploymentLabel + "_" + str(apiServer.GeneratePodName())
pod = Pod(podName, deployment.cpuCost, deployment.deploymentLabel)
pod.status = "RUNNING"
pod.requests = [ 'Req 1' ]
pod.available_cpu -= 1

podList = [pod, pod]

hpa = HPA(apiServer, _hpaCtlLoop, HPA_INFO)


class TestUtilisation(unittest.TestCase):
	def test_average_utilisation(self):
		load = hpa.calculateAvgUtil(deployment, podList)
		self.assertEqual(load, 0.5)

class TestController(unittest.TestCase):