def DeletePod(self, request, context): logger.info("Deleting pod from Network Controller {}".format( request.name)) param = reset_param(HandlerParam()) param.name = request.name param.namespace = request.namespace return run_arktos_workflow(wffactory().k8sPodDelete(param=param))
def CreatePod(self, request, context): if request.host_ip == '': return ReturnCode( code=CodeType.TEMP_ERROR, message="Missing hostIP during pod create or update") logger.info("Creating pod from Arktos Service {}".format(request.name)) param = reset_param(HandlerParam()) param.name = request.name param.namespace = request.namespace param.body['status'] = {} param.body['metadata'] = {} param.body['status']['hostIP'] = request.host_ip param.body['metadata']['namespace'] = request.namespace param.body['status']['phase'] = request.phase param.body['metadata']['tenant'] = request.tenant param.extra = {} if request.arktos_network != "": param.extra["arktos_network"] = request.arktos_network if len(request.interfaces) > 0: param.extra["interfaces"] = list() itf_string = '[' for interface in request.interfaces: itf_string += '{"name": "{}", "ip": "{}", "subnet": "{}"},'.format( interface.name, interface.ip, interface.subnet) itf_string = itf_string[:-1] + ']' param.extra.interfaces = itf_string return run_arktos_workflow(wffactory().k8sPodCreate(param=param))
def DeleteService(self, request, context): logger.info("Deleting servoce from Network Controller {}".format( request.name)) param = reset_param(HandlerParam()) param.name = request.name param.body['metadata'] = {} param.body["metadata"]["namespace"] = request.namespace param.body['metadata']['tenant'] = request.tenant return run_arktos_workflow(wffactory().k8sServiceDelete(param=param))
def CreateServiceEndpointProtobuf(self, request, context): logger.info( "Create Service Endpoint from Network Controller {}".format( request.name)) param = HandlerParam() param.name = request.name param.body['metadata'] = {} param.body["metadata"]["namespace"] = request.namespace param.extra = request return run_arktos_workflow(wffactory().k8sEndpointsUpdate(param=param))
def CreateNode(self, request, context): logger.info("Creating droplet from Arktos Service {}".format( request.ip)) param = reset_param(HandlerParam()) param.body['status'] = {} param.body['status']['addresses'] = list() param.body['status']['addresses'].append({}) param.body['status']['addresses'][0]["type"] = "InternalIP" param.body['status']['addresses'][0]["address"] = request.ip return run_arktos_workflow(wffactory().k8sDropletCreate(param=param))
def DeleteNetworkPolicy(self, request, context): logger.info( "Deleting network policy from Network Controller {}".format( request.name)) param = reset_param(HandlerParam()) param.name = request.name param.body['metadata'] = {} param.body["metadata"]["namespace"] = request.namespace param.extra = request.tenant return run_arktos_workflow( wffactory().k8sNetworkPolicyDelete(param=param))
def CreateNetworkPolicy(self, request, context): logger.info("Creating network policy from Arktos Service {}".format( request.name)) param = reset_param(HandlerParam()) param.name = request.name param.namespace = request.namespace param.body['status'] = {} param.body['metadata'] = {} param.body['metadata']['namespace'] = request.namespace param.body['metadata']['tenant'] = request.tenant param.spec = json.loads(request.policy) param.extra = {} return run_arktos_workflow( wffactory().k8sNetworkPolicyCreate(param=param))
def CreateService(self, request, context): logger.info( "Create scaled endpoint from Network Controller {} {} {}.".format( request.name, request.namespace, request.tenant)) param = reset_param(HandlerParam()) param.name = request.name param.body['metadata'] = {} param.extra = {} param.body['metadata']['namespace'] = request.namespace param.spec["clusterIP"] = request.ip logger.info("From grpc server: Service IP is {}".format(request.ip)) param.extra["arktos_network"] = request.arktos_network param.extra["tenant"] = request.tenant return run_arktos_workflow(wffactory().k8sServiceCreate(param=param))
def CreateServiceEndpoint(self, request, context): logger.info( "Create Service Endpoint from Network Controller {}".format( request.name)) param = reset_param(HandlerParam()) param.name = request.name param.body['metadata'] = {} param.body["metadata"]["namespace"] = request.namespace ips = json.loads(request.backend_ips_json) ports = json.loads(request.ports_json) param.extra = {} param.extra["request"] = request param.extra["backend_ips"] = ips param.extra["ports"] = ports for ip in ips: logger.info(ip) for port in ports: logger.info(port) return run_arktos_workflow(wffactory().k8sEndpointsUpdate(param=param))
def DeleteNode(self, request, context): logger.info("Deleting droplet from Network Controller {}".format( request.name)) param = reset_param(HandlerParam()) param.name = request.name return run_arktos_workflow(wffactory().DropletDelete(param=param))