Exemplo n.º 1
0
    def __init__(
        self,
        hostname: str,
        resources: typing.Optional[dict] = None,
        bucket_id: typing.Optional[ht.BucketId] = None,
    ) -> None:
        resources = resources or ht.ResourceDict({})
        private_ip: typing.Optional[ht.IpAddress]
        if SchedulerNode.ignore_hostnames:
            private_ip = None
        else:
            try:
                private_ip = ht.IpAddress(socket.gethostbyname(hostname))
            except Exception as e:
                logging.warning("Could not find private ip for %s: %s", hostname, e)
                private_ip = None

        Node.__init__(
            self,
            node_id=DelayedNodeId(ht.NodeName(hostname)),
            name=ht.NodeName(hostname),
            nodearray=ht.NodeArrayName("unknown"),
            bucket_id=bucket_id or ht.BucketId(str(uuid4())),
            hostname=ht.Hostname(hostname),
            private_ip=private_ip,
            instance_id=None,
            vm_size=ht.VMSize("unknown"),
            location=ht.Location("unknown"),
            spot=False,
            vcpu_count=1,
            memory=ht.Memory(0, "b"),
            infiniband=False,
            state=ht.NodeStatus("running"),
            target_state=ht.NodeStatus("running"),
            power_state=ht.NodeStatus("running"),
            exists=True,
            placement_group=None,
            managed=False,
            resources=ht.ResourceDict(resources),
            software_configuration=ImmutableOrderedDict({}),
            keep_alive=False,
        )
Exemplo n.º 2
0
 def __init__(
     self,
     hostname: str,
     resources: Optional[dict] = None,
     vm_size: Optional[ht.VMSize] = None,
     location: Optional[ht.Location] = None,
     vcpu_count: Optional[int] = None,
     memory: Optional[ht.Memory] = None,
     placement_group: Optional[ht.PlacementGroup] = None,
 ) -> None:
     resources = resources or ht.ResourceDict({})
     if vm_size:
         assert (vm_size and location
                 ), "You must specify location when specifying vm_size"
     vm_size = vm_size or ht.VMSize("unknown")
     location = location or ht.Location("unknown")
     aux = vm_sizes.get_aux_vm_size_info(location, vm_size)
     Node.__init__(
         self,
         node_id=DelayedNodeId(ht.NodeName(hostname)),
         name=ht.NodeName(hostname),
         nodearray=ht.NodeArrayName("unknown"),
         bucket_id=ht.BucketId("unknown"),
         hostname=ht.Hostname(hostname),
         private_ip=None,
         vm_size=vm_size,
         location=location,
         spot=False,
         vcpu_count=aux.vcpu_count,
         memory=aux.memory,
         infiniband=False,
         state=ht.NodeStatus("running"),
         power_state=ht.NodeStatus("running"),
         exists=True,
         placement_group=placement_group,
         managed=False,
         resources=ht.ResourceDict(resources),
         software_configuration=ImmutableOrderedDict({}),
         keep_alive=True,
     )
     assert self.exists
Exemplo n.º 3
0
    def __init__(
        self,
        hostname: str,
        resources: typing.Optional[dict] = None,
        bucket_id: typing.Optional[ht.BucketId] = None,
        **overrides: typing.Any,
    ) -> None:
        resources = resources or ht.ResourceDict({})

        node_init_args = dict(
            self=self,
            node_id=DelayedNodeId(ht.NodeName(hostname)),
            name=ht.NodeName(hostname),
            nodearray=ht.NodeArrayName("unknown"),
            bucket_id=bucket_id or ht.BucketId(str(uuid4())),
            hostname=ht.Hostname(hostname),
            private_ip=None,
            instance_id=None,
            vm_size=ht.VMSize("unknown"),
            location=ht.Location("unknown"),
            spot=False,
            vcpu_count=1,
            memory=ht.Memory(0, "b"),
            infiniband=False,
            state=ht.NodeStatus("running"),
            target_state=ht.NodeStatus("running"),
            power_state=ht.NodeStatus("running"),
            exists=True,
            placement_group=None,
            managed=False,
            resources=ht.ResourceDict(resources),
            software_configuration=ImmutableOrderedDict({}),
            keep_alive=False,
        )
        node_init_args.update(overrides)
        Node.__init__(**node_init_args)
Exemplo n.º 4
0
    def __init__(
        self,
        definition: NodeDefinition,
        limits: BucketLimits,
        max_placement_group_size: int,
        nodes: List["Node"],
        artificial: bool = False,
    ) -> None:
        # example node to be used to see if your job would match this
        self.__definition = definition

        assert limits
        self.limits = limits
        self.max_placement_group_size = max_placement_group_size
        self.priority = 0
        # list of nodes cyclecloud currently says are in this bucket
        self.nodes = nodes
        self.__decrement_counter = 0
        example_node_name = ht.NodeName("{}-0".format(definition.nodearray))
        self._artificial = artificial

        # TODO infiniband
        from hpc.autoscale.node.node import Node

        self.__example = Node(
            node_id=DelayedNodeId(example_node_name),
            name=example_node_name,
            nodearray=definition.nodearray,
            bucket_id=definition.bucket_id,
            hostname=None,
            private_ip=None,
            instance_id=None,
            vm_size=definition.vm_size,
            location=self.location,
            spot=definition.spot,
            vcpu_count=self.vcpu_count,
            memory=self.memory,
            infiniband=False,
            state=ht.NodeStatus("Off"),
            target_state=ht.NodeStatus("Off"),
            power_state=ht.NodeStatus("Off"),
            exists=False,
            placement_group=definition.placement_group,
            managed=False,
            resources=self.resources,
            software_configuration=definition.software_configuration,
            keep_alive=False,
        )