Esempio n. 1
0
 def __init__(self):
     self.node_status = V1NodeStatus(
         addresses=self.get_status_address(),
         allocatable=self.get_status_allocatable(),
         capacity=self.get_status_capacity(),
         conditions=self.get_status_condition(),
         daemon_endpoints=self.get_status_daemon_endpoints(),
         node_info=self.get_status_node_info())
     self.node = V1Node(api_version='v1',
                        kind='Node',
                        metadata=self.get_object_metadata(),
                        spec=self.get_node_spec(),
                        status=self.node_status)
     self.__node = self.node
     self.__node_status = self.node_status
def mock_k8s_node(config):
    if not isinstance(config, MockK8sNodeConfig):
        raise TypeError("Wrong config type")

    node = V1Node()

    node.metadata = V1ObjectMeta(name=config.name, labels=config.labels)

    node.spec = V1NodeSpec(unschedulable=config.unschedulable)

    address_ip = V1NodeAddress(config.internal_ip, "InternalIP")
    conditions = [V1NodeCondition(type="Ready", status=config.ready)]
    node.status = V1NodeStatus(addresses=[address_ip],
                               conditions=conditions,
                               capacity=config.capacity,
                               allocatable=config.allocatable)

    return node
Esempio n. 3
0
def _mock_v1_node(internal_ip, hostname):
    node = V1Node()
    address_ip = V1NodeAddress(internal_ip, "InternalIP")
    address_hostname = V1NodeAddress(hostname, "Hostname")
    node.status = V1NodeStatus(addresses=[address_ip, address_hostname])
    return node